// @author: caoshi
// @date: 2021-06-08 07:56
package v1

import (
	"demo08_paramsbind/src/util/captcha"
	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
	"net/http"
)

func InitCaptcha(c *gin.Context) {
	captchaId, b64s, _ := captcha.GenerateCaptcha(captcha.String)
	//fmt.Println("生成的验证码 ", b64s)
	// 获取session, 并存储生成的验证码Id
	session := sessions.Default(c)
	session.Set(SessionId, captchaId)
	_ = session.Save()
	c.String(http.StatusOK, b64s)
}
